package com.itheima.api.map.demo05;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

public class MapTraverseDemo_2 {

    public static void main(String[] args) {

        Map<String, String> map = new HashMap<>();
        map.put("蓝湛", "蓝忘机");
        map.put("魏婴", "魏无羡");
        map.put("蓝涣", "蓝曦臣");
        System.out.println(map);

        Set<Map.Entry<String, String>> entrySet = map.entrySet();

        for(Map.Entry<String, String> entry : entrySet){
            System.out.println(entry.getKey() + "-1-" + entry.getValue());
        }

        map.forEach(new BiConsumer<String, String>() {
            @Override
            public void accept(String s, String s2) {
                System.out.println(s + "-2-" + s2);
            }
        });

        map.forEach((key, value) -> System.out.println(key + "-3-" + value));
    }
}
